﻿namespace LearnDSHeap;

public class HeapSort
{
    public void Sort(int[] arr, int n)
    {
        Heaps h = new Heaps();
        for (int i = 0; i < n; i++)
        {
            h.Insert(arr[i]);
        }

        int k = n - 1;
        for (int i = 0; i < n; i++)
        {
            arr[k] = h.DeleteMax();
            k--;
        }
    }

    public void Display(int[] arr, int n)
    {
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(arr[i] + " ");
        }

        Console.WriteLine();
    }
}